//
//  HNStudentSignModel.m
//  优学荟管理系统
//
//  Created by edz on 2017/12/7.
//  Copyright © 2017年 星道三好. All rights reserved.
//

#import "HNStudentSignModel.h"

@implementation HNStudentSignModel

// 实例化
- (instancetype)init_ValuForKeyWithDict:(NSDictionary *)Dict {
    self = [super init];
    if (self) {
        [self setValuesForKeysWithDictionary:Dict];
    }
    return self;
}

// KVO
- (void)setValue:(id)value forUndefinedKey:(NSString *)key {
    
    if ([key isEqualToString:@"id"]) {
        
        self.enrollInfoId = value;
    }
    
    // 次数
    if ([key isEqualToString:@"record"]) {
        
        self.Num = value;
    }
    
    // 名称 图片
    if ([key isEqualToString:@"owner"]) {
        
        self.Name = value[@"petName"];
        self.avatar = value[@"avatar"];
        self.User_ID = value[@"uid"];
    }
    
    if ([key isEqualToString:@"showStatus"]) {
        
        self.State = [self GetStateStrOfIndex:[value integerValue]];
        self.StateImage = [self GetStateImageOfIndex:[value integerValue]];
    }
}

/** 根据状态获取字符串 */
- (NSString *)GetStateStrOfIndex:(NSInteger)Index {
    
    switch (Index) {
            case 0:
            return @"隐藏";
            case 1:
            return @"到课";
            case 3:
            return @"请假";
            case 2:
            return @"缺勤";
        default:
            return @"";
    }
}

/** 根据状态获取颜色值 */
- (UIImage *)GetStateImageOfIndex:(NSInteger)Index {
    
    switch (Index) {
        case 0:
            return [UIImage imageNamed:@"bg_appoint"];
        case 1:
            return [UIImage imageNamed:@"bg_daoke_student_sign"];
        case 3:
            return [UIImage imageNamed:@"bg_qingjiabg_daoke_student_sign"];
        case 2:
            return [UIImage imageNamed:@"bg_queqingbg_daoke_student_sign"];
        default:
            return [UIImage imageNamed:@""];
    }
}


- (void)SetStatus:(NSNumber *)Status {
    
    // 1缺勤 2请假 10到课
    NSInteger Index = [Status isEqualToNumber:@1] ? 2:3;
    if ([Status isEqualToNumber:@10]) {
        Index = 1;
    }
    self.State = [self GetStateStrOfIndex:Index];
    self.StateImage = [self GetStateImageOfIndex:Index];
}


@end
